package com.asset.salesforce.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.asset.salesforce.dao.EmployeeDaoImpl;
import com.asset.salesforce.domain.Employee;

@Service
@Transactional(readOnly=true)
public class EmployeeService {
	
	@Autowired
	EmployeeDaoImpl employeeDaoImpl;
	
	@Transactional(readOnly=false)
	public void addEmployee(Employee employee) {
		employeeDaoImpl.addEmployee(employee);
	}
	public Employee getEmployeeByEmailAndPassword(String email,String password) {
		return employeeDaoImpl.getByEmailAndPassword(email,password);
		
	}
	public Employee getEmployeeByEmail(String email) {
		return employeeDaoImpl.getByEmail(email);
		
	}
	public Employee getOwnerByCompanyName(String companyName){
		
		return employeeDaoImpl.getOwnerByCompanyName(companyName);
	}
	@Transactional(readOnly=false)
	public void saveOrUpdateEmployee(Employee employee){
		employeeDaoImpl.saveOrupdate(employee);
	}
	
	public Employee loadEmployeeById(Integer id){
		Employee employee = employeeDaoImpl.loadEmployee(id);
		if(employee != null){
			return employee;
		}else{
			return null;
		}
	}
	
	public List<Employee> getAll(){
		return employeeDaoImpl.getAllEmplyee();
	}
	
	public Employee getById(Integer id){
		return employeeDaoImpl.getById(id);
	}

}
